package com.fantastic.service.zjs.impl;

import com.fantastic.common.exception.enums.RespStatusInfo;
import com.fantastic.common.exception.sql.DeleteException;
import com.fantastic.common.exception.sql.InsertException;
import com.fantastic.common.exception.sql.SelectException;
import com.fantastic.common.exception.sql.UpdateException;
import com.fantastic.common.utils.IsEmptyUtils;
import com.fantastic.mapper.zjs.MemberCouponsMapper;
import com.fantastic.model.pojo.zjs.MemberCoupons;
import com.fantastic.service.zjs.MemberCouponsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: rxx
 * @since: 2024/6/4 20:08
 * @description: 会员卡优惠券关联信息service接口
 */
@Service
public class MemberCouponsServiceImpl implements MemberCouponsService {

    @Resource
    private MemberCouponsMapper memberCouponsMapper;

    /**
     * 查询会员卡优惠券关联信息
     *
     * @param memberCoupons
     * @return
     */
    @Override
    public List<MemberCoupons> listMembersCoupons(MemberCoupons memberCoupons) {
        List<MemberCoupons> memberCouponsList = memberCouponsMapper.listMembersCoupons(memberCoupons);
        IsEmptyUtils.listIsEmpty(new SelectException(RespStatusInfo.SELECT_NULL), memberCouponsList);
        return memberCouponsList;
    }

    /**
     * 查询单个会员卡优惠券关联信息
     *
     * @param memberId
     * @param couponsId
     * @return
     */
    @Override
    public MemberCoupons getMemberCoupons(Integer memberId, Integer couponsId) {
        IsEmptyUtils.integerIsEmpty(new SelectException(RespStatusInfo.DATA_ERROR), memberId, couponsId);
        return memberCouponsMapper.getMemberCoupons(memberId, couponsId);
    }

    /**
     * 添加会员卡优惠券关联信息
     *
     * @param memberCoupons
     * @return
     */
    @Override
    public Integer insertMemberCoupons(MemberCoupons memberCoupons) {
        IsEmptyUtils.integerIsEmpty(new InsertException(RespStatusInfo.DATA_ERROR),
                memberCoupons.getCouponsId(), memberCoupons.getMemberId());
        return memberCouponsMapper.insertMemberCoupons(memberCoupons);
    }

    /**
     * 修改会员卡优惠券关联信息（未实现）
     *
     * @param memberCoupons
     * @return
     */
    @Override
    public Integer updateMemberCoupons(MemberCoupons memberCoupons) {
        IsEmptyUtils.integerIsEmpty(new UpdateException(RespStatusInfo.DATA_ERROR),
                memberCoupons.getCouponsId(), memberCoupons.getMemberId());
        return memberCouponsMapper.updateMemberCoupons(memberCoupons);
    }

    /**
     * 删除会员卡优惠券关联信息
     *
     * @param memberId
     * @param couponsId
     * @return
     */
    @Override
    public Integer deleteMemberCoupons(Integer memberId, Integer couponsId) {
        IsEmptyUtils.integerIsEmpty(new DeleteException(RespStatusInfo.SELECT_NULL), memberId, couponsId);
        return memberCouponsMapper.deleteMemberCoupons(memberId, couponsId);
    }


}
